home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindspring.com!usenet
- From: wdnick@mindspring.com (William "Doug" Nicholson)
- Newsgroups: comp.lang.c++
- Subject: Newbie question about function calling.
- Date: Fri, 08 Mar 1996 08:45:49 GMT
- Organization: MindSpring Enterprises
- Message-ID: <4hohd3$r9@brickbat.mindspring.com>
- Reply-To: wdnick@mindspring.com
- NNTP-Posting-Host: wdnick.mindspring.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- I'm having a problem somewhere between the following two functions.
- My main calls the function 'counter' (shown below) which in turn calls
- 'getinfo' by trying to assign 'getinfo's return value to the string
- variable 'filename'. 'Getinfo' prompts the user to enter a filename
- and stores it in the string 'infile'. I've added a couple of lines
- below and started them in my post with the > so they will stand out.
- In the first one (in the getinfo function), the printf line prints
- whatever I type in at the prompt. Theoretically this should be passed
- to 'filename' in the other function. Well, the printf that tries to
- print "FILE = 'filename'" stops after "FILE =" and the computer locks
- up.
-
- Anybody got any idea what's happening here? Have I overlooked a
- really stupid thing or what?
-
- Thanks for any help. The problem area is listed below.
-
-
-
-
-
-
-
- char getinfo(void)
- /*****************************************************************
- * This function prompts the user for a filename and returns it. *
- *****************************************************************/
- {
- char infile[15]; /* file to process */
-
- printf("Enter the path and filename of a file to process ");
- printf("or enter XX to quit >");
- scanf("%s", infile);
-
- > printf("FILE = %s\n\n", infile);
-
- return(infile[15]);
- } /* end function getinfo */
-
- int counter(void)
- /*****************************************************************
- * This function counts the number of times that each character *
- * is used in a file and returns the count. *
- *****************************************************************/
- {
- int i, /* lengths of triangle sides */
- count[128]; /* character count array */
-
- char chr,
- filename[15] = "",
- foo[2] = "1";
-
- FILE *inp, /* input file pointer */
- *outp; /* output file pointer */
-
- filename[15] = getinfo();
-
- > printf("FILE = %s\n\n", filename);
-
-
-
- William D. Nicholson wdnick@mindspring.com
- Mechanical Engineering Student
- Southern College of Technology It is what you make it.
- Under heavy construction: http://www.mindspring.com/~wdnick/home.html
-
-